1. Technical Field
The present invention is directed to an improvement in compilers and related software development tools and in particular to the verification of data dependencies in computer programs at compile-time.
2. Prior Art
It is common to utilize data dependencies in computer programs. Data dependencies are used in computer programming because they can provide the advantages of memory efficiencies and run-time execution efficiencies.
Where data dependencies are created, program code can be written which will take advantage of characteristics or rules relating to the data structures which are not expressly defined in the programming language, or the data type definition, themselves. Examples of such data dependencies include requirements that two different data structures have identical lengths or that two data elements be adjacent to one another in memory. The programmer can take advantage of these known relationships between data structures to create programs which execute more quickly or with the need for less memory than would otherwise be the case.
Good programming practice requires that such assumptions or rules relating to how the data may be manipulated (the data dependencies) are indicated in the documentation accompanying the computer code. However, the error-free use of data which is subject to the data dependencies relies on the understanding of programmers, rather than on any restriction imposed by the compiler. Problems may arise when modifications are made to the computer program at which time the documentation is not referenced or available, or where the documentation is poorly prepared or inadequately laid out.
Furthermore, in writing complex computer systems, it is often preferable to define data or data types at a particular point in a computer program and to make use of the data or data type at different points in the computer systems or programs which may be remote from the data definition point. The data dependencies relied upon at the remote point may not be referenced in documentation at the data definition point. When modifications are later made to the computer program, the data dependencies may not be apparent to the programmer making the modifications, with the result that errors may arise in the program.
Typically, computer programmers use programming language features which can be utilized to verify such data dependencies at run-time. An example of such a computing language function is the assert macro included in libraries supplied with many compilers for the C programming language. Such macros or programming language features will evaluate specified characteristics of data structures at the point in the execution of the program where the statement or macro is found.
The difficulty with such an approach is that additional code is introduced into the computer program (which in some cases may be minimized or eliminated by compiler optimization). To eliminate this additional code, it is necessary to go through the step of removing the verifying macros or statements in the program entirely after the testing phase of the program development.
The further difficulty with this prior art approach is that because the verification occurs at run-time, if data subject to a data dependency is incorrectly used in a particular piece of programming code which is not executed during testing of the program the error may not be uncovered until some time after the program is put into use. Furthermore, the identification of errors during program testing does not occur at a single time; the program must be put through successive tests to uncover each such error. Finally, such error identification using, for example, the assert macro does not occur until run-time.
It is therefore desirable to have an improved compiler, assembler, or related tools, capable of verifying the correct use of data subject to data dependencies, without introducing additional run-time costs or increased run-time code, which will identify data dependency errors at a single time, and which compiler will not rely on run-time testing of the code to uncover such errors.